//
//  MsgSettingViewController.m
//  SIPphone
//
//  Created by wrt on 13-11-14.
//  Copyright (c) 2013年 wrtsoft. All rights reserved.
//

#import "MsgSettingViewController.h"

@interface MsgSettingViewController ()

@end

@implementation MsgSettingViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
        self.title = @"留言设置";
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    NSString *isOpenMsg = [[NSString alloc] init];
    isOpenMsg = [defaults objectForKey:@"SAVEISOPENMESSAGE"];
    if (isOpenMsg.length > 0)
    {
        if ([isOpenMsg isEqualToString:@"YES"])
        {
            [self.openSwitch setOn:YES];
        }
        else if ([isOpenMsg isEqualToString:@"NO"])
        {
            [self.openSwitch setOn:NO];
        }
    }

}
- (IBAction)openMsgSwitch:(id)sender
{
    UISwitch *switchControl = (UISwitch *)sender;
    SIPInterface *interface = [SIPInterface shareSIPInterface];
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    BOOL isOpenSound = switchControl.on;
    if (isOpenSound == YES)
    {
        [interface isOpenMsg:YES];
        [defaults setObject:@"YES" forKey:@"SAVEISOPENMESSAGE"];
    }
    else
    {
        [interface isOpenMsg:NO];
        [defaults setObject:@"NO" forKey:@"SAVEISOPENMESSAGE"];
    }
    [defaults synchronize];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
